module UsersHelper
  
  $users_controller = "users"
  $core_controller = "core"
  
  $super_privilege = 1
  $login = "core/templates/login"
  $super_logout = "users/templates/super_logout"
  $logout = "users/templates/logout"
  $main_edit_page = "users/edit"
  $edit = "users/templates/edit"
  $edit_super = "users/templates/edit_super"
  $main_show_page = "users/show"
  $show_all = "users/templates/show_all_users"
  
  def show_edit user
    if user.privilege == $super_privilege
       @menutype = $super_logout
       @body = $edit_super
    #  redirect_to :controller => "core", :action => "index", :body => "users/templates/edit_super"
    else
      @menutype = $logout
      @body = $edit
    #  redirect_to :controller => "core", :action => "index", :body => "users/templates/edit"
    end
    @user = user
    render :template => $main_edit_page

  end
  
  def show_all user_session
    if user_session == nil
      redirect_to :controller => "core", :action => "index"
    else
      
      @user = User.find(user_session)
      if @user.privilege == $super_privilege
        @menutype = $super_logout
      else
        @menutype = $logout
      end
      
      flash[:notice] = nil
      @body = $show_all
      @users = User.find(:all, :order => "name")
      puts @users[0].class.to_s
      
      render :template => $main_show_page
    end
  end
  
  
end
